package cn.tedu.batch.transformation

import org.apache.flink.api.scala.ExecutionEnvironment

/**
 * @author Amos
 * @date 2022/5/19
 */

object BatchReduceDemo {
  def main(args: Array[String]): Unit = {
    val env = ExecutionEnvironment.getExecutionEnvironment
    import org.apache.flink.api.scala._
    val source: DataSet[(String, Int)] = env.fromCollection(List(("java", 1), ("flink", 2),("java", 1), ("java", 1)))

    val result = source.groupBy(0).reduce((x, y) => {(x._1, x._2 + y._2)})

    result.print()
  }

}
